home *** CD-ROM | disk | FTP | other *** search
- #include <egb.h>
- #include <mos.h>
- #include <fmc.h>
- #include <string.h>
- #include "dabe.h"
-
- #define DWORD(x) *((unsigned int *)(x))
- #define WORD(x) *((unsigned short int *)(x))
-
- extern char work[];
- extern char swork[];
- extern char mwork[];
- extern char para[];
- extern int ox, oy;
- extern int event1_x, event1_y;
- extern int event2_x, event2_y;
- extern int event3_x, event3_y;
- extern int botton_x, botton_y[];
- extern short rad;
-
- char mp[ (32 + 7) / 8 * 4 * 32 ];
-
-
- short MOS_read( float lox, float loy, short komsu, char *msg, short arraylen, short page, short putflag )
- {
- /************************************************************************/
- /* i lox == MOUSEの移動範囲の上端の開始x座標(16ドット単位) */
- /* i loy == MOUSEの移動範囲の上端の開始y座標(16ドット単位) */
- /* i komsu == 選択項目の数 */
- /* c *msg == メッセージ配列の先頭アドレス */
- /* i arraylen == メッセージの長さ */
- /* */
- /* */
- /* メッセージ配列の先頭にタイトル名を入れ、その後に選択項目名を入れる。 */
- /* メッセージ配列は、配列名〔項目数〕〔xlen〕の形式をとること。 */
- /* その後、この関数を呼び出すこと。 */
- /* 返り値 == 選択項目の番号(komnum) */
- /************************************************************************/
-
- int ch, x, y;
- short i;
- static int mr_ox, mr_oy;
- static int save_mr_ox, save_mr_oy;
- static short border[40]; /* 選択項目BOXの境界y座標 */
- static short linenum; /* 選択項目の番号 */
- short sound;
-
- /* 画面設定 */
- EGB_writePage( work, page );
- EGB_paintMode( work, 0x22);
-
- if( (putflag == NEW) || (putflag == SAVE) ){
-
- linenum = 1;
-
- /* 境界の設定 */
- for( i = 0; i <= komsu; i++ )
- border[i] = ( (loy + i) * 16 ) + 1;
-
- /* Titleを表示 */
- if( arraylen != 70 )
- sound = SOUND_ON;
- else
- sound = SOUND_OFF;
- strcpy(swork, msg);
- g_wintitle( lox, (lox + arraylen / 2), (loy - 1), TITCOL, UTICOL, DTICOL, TCHCOL, swork, page, sound );
-
- strcpy(swork, msg + arraylen);
- g_winkom( lox, (lox + arraylen / 2), loy, RKOCOL, UKOCOL, DKOCOL, CHRCOL, swork, page );
- for( i = 2; i <= komsu; i++ ){
- strcpy( swork, msg + (i * arraylen) );
- g_winkom( lox, (lox + arraylen / 2), loy + i - 1, KOMCOL, UKOCOL, DKOCOL, CHRCOL, swork, page );
- }
- }
-
- /* MOUSE移動範囲等の設定 */
- cmwork( mwork );
- MOS_start( mwork, 4096 );
- MOS_horizon( (lox * 16) + 1, ( (lox + arraylen / 2) * 16) - 1);
- MOS_vertical( (loy * 16) + 1, ( (loy + komsu) * 16) - 1);
- if( (putflag == NEW) || (putflag == SAVE) )
- MOS_setpos( mr_ox = (lox * 16) + 1, mr_oy = (loy * 16) + 1);
- else
- MOS_setpos( mr_ox = save_mr_ox , mr_oy = save_mr_oy );
-
- getcurbak( mr_ox, mr_oy );
- putcur( mr_ox, mr_oy );
-
-
- /* MOUSE読み取りスタート*/
- do
- {
- MOS_rdpos(&ch, &x, &y);
-
- if ( (y < border[linenum - 1]) || (y > border[linenum]) )
- {
- putcurbak( mr_ox, mr_oy );
-
- strcpy( swork, msg + (linenum * arraylen) );
- g_winkom( lox, (lox + arraylen / 2), (linenum + loy - 1), KOMCOL, UKOCOL, DKOCOL, CHRCOL, swork, page );
- if ( y < border[linenum - 1] )
- {
- while( (y <= border[linenum - 1]) && (linenum > 1) )
- linenum--;
- }
- else
- {
-
- while( (y >= border[linenum]) && (linenum < komsu) )
- linenum++;
- }
-
- strcpy( swork, msg + (linenum * arraylen) );
- g_winkom( lox, ( lox + arraylen / 2 ),( linenum + loy - 1), RKOCOL, UKOCOL, DKOCOL, CHRCOL, swork, page );
-
- getcurbak( x, y );
- putcur( x, y );
-
- }else{
- if( (x != mr_ox) || (y != mr_oy) ){
- putcurbak( mr_ox, mr_oy );
- getcurbak( x, y );
- putcur( x, y );
- }
- }
-
- mr_ox = x;
- mr_oy = y;
-
- }while( ch == 0 );
-
- putcurbak( mr_ox, mr_oy );
-
- if( putflag == SAVE || putflag == RESTART ){
- save_mr_ox = mr_ox;
- save_mr_oy = mr_oy;
- }
-
- MOS_end();
-
- if( page == page1 ){
- WORD( para + 0 ) = 0;
- WORD( para + 2 ) = 0;
- WORD( para + 4 ) = 639;
- WORD( para + 6 ) = 479;
- EGB_writePage( work, 0x01 );
- EGB_color( work, 0, 0 );
- EGB_color( work, 2, 0 );
- EGB_rectangle( work, para );
- }
-
- switch(ch){
- case 1: BPB_freeon2( 10, 2000 );
- return linenum;
- case 2: return Rbotton;
- case 3: return Rbotton;
- }
- }
-
- void mos_start()
- {
- cmwork( mwork );
- MOS_start( mwork, 4096 );
- MOS_horizon( 0, 639 );
- MOS_vertical( 0, 479 );
- MOS_setpos( ox, oy );
- getcurbak( ox, oy );
- putcur( ox, oy );
- }
-
- void mos_end()
- {
- putcurbak( ox, oy );
- MOS_end();
- }
-
- short mos_sub()
- {
- int ch, x, y;
- short i;
-
- MOS_rdpos( &ch, &x, &y );
-
- if( ( x != ox ) || ( y != oy ) ){
- putcurbak( ox, oy );
- getcurbak( x, y );
- putcur( x, y );
- }
- ox = x;
- oy = y;
-
- if( ch == 1 ){
- if( (x > event2_x) && (x < (event2_x + 31)) && (y > event2_y) && (y < (event2_y + 31)) ){
- BPB_freeon2( 10, 2500 );
- return 2;
- }
- if( (x > event3_x) && (x < (event3_x + 31)) && (y > event3_y) && (y < (event3_y + 31)) ){
- BPB_freeon2( 10, 3000 );
- return 3;
- }
- if( ( x > botton_x ) && ( x < botton_x + 16 ) ){
- for( i = 1; i <= 12; i++ ){
- if( y > botton_y[ i - 1 ] && y < botton_y[ i - 1 ] + 16 )
- break;
- }
- if( i <= 12 )
- return i + 10;
- }
- }
-
- if( ch == 2 )
- return -2;
-
- return 0;
-
- }
-
-
-
-
- short MOS_loop()
- {
- int ch, x, y;
-
- cmwork( mwork );
- MOS_start( mwork, 4096 );
- MOS_resolution( 0, 12 );
- MOS_disp(0);
-
- do
- {
- MOS_rdpos( &ch, &x, &y );
- }while( (ch != 1) && (ch != 2) && (ch != 3) );
-
- MOS_end();
-
- ch *= (-1);
- return ch;
- }
-
- short MOS_YesNo()
- {
- short x, y;
-
- char mosmsg[3][10] = { "選択","Yes","No" };
- short ret;
-
- rad--;
- get_xy( &x, &y );
-
- ret = MOS_read( x + 15, y + 4.5, 2, mosmsg[0], 10, page0, NEW );
- return ret;
-
- }
-
- void cmwork( char *mwork )
- {
- short count;
-
- for( count = 0; count < 4096; count++ ){
- *mwork = (char)0x00;
- mwork++;
- }
- }
-
- void putcur( int x, int y )
- {
- EGB_writePage( work, 0x01 );
-
- DWORD(para + 0) = 0x28000+0x56*256 ;
- WORD(para + 4) = 0x108 ;
- WORD(para + 6) = x;
- WORD(para + 8) = y;
- WORD(para + 10) = x + 31;
- WORD(para + 12) = y + 31;
- EGB_color( work, 0, 9 );
- EGB_putBlockColor( work, 0 ,para ) ;
-
- WORD(para + 0) = x + 3;
- WORD(para + 2) = y + 3 ;
- WORD(para + 4) = 1;
- WORD(para + 6) = 0;
- DWORD(para + 8) = 9;
- EGB_color( work, 2, 15 ) ;
- EGB_paint( work, para ) ;
- }
-
- void getcurbak( int x, int y )
- {
- EGB_writePage( work, 0x01 );
- DWORD( mp + 0 ) = (unsigned int)( mp + 14 );
- WORD( mp + 4 ) = 0x014;
- WORD( mp + 6 ) = x;
- WORD( mp + 8 ) = y;
- WORD( mp + 10 ) = x + 18;
- WORD( mp + 12 ) = y + 21;
- EGB_getBlock( work, mp );
- }
-
- void putcurbak( int x, int y )
- {
- EGB_writePage( work, 0x01 );
- DWORD( mp + 0 ) = (unsigned int)( mp + 14 );
- WORD( mp + 4 ) = 0x014;
- WORD( mp + 6 ) = x;
- WORD( mp + 8 ) = y;
- WORD( mp + 10 ) = x + 18;
- WORD( mp + 12 ) = y + 21;
- EGB_putBlock( work, 0, mp );
- }
-
-